package com.admin.action;

import com.uni.service.Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * --------------project-------------
 *
 * @Author Unirithe  - Mr.Chao
 * - CSDN:
 * https://blog.csdn.net/Unirithe
 * - GitHub:
 * https://github.com/unirithe
 * @create 2021/12/29 9:40
 * ------------------------------------------
 */
@WebServlet(name = "DeleteCommoidtyAction", urlPatterns = "/adminDeleteCommoidty")
public class DeleteCommoidtyAction extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer id = Integer.parseInt(req.getParameter("id"));
        try{
            Service.commodity.deleteCommodity(id);
        } catch (Exception e){
            e.printStackTrace();
            resp.getWriter().write("false");
        }
        resp.getWriter().write("true");
    }
}
